package cn.com.roy.thread.t4_1_11.lockmethdtest2;

import java.util.concurrent.locks.Condition;
import java.util.concurrent.locks.ReentrantLock;

public class MyService {
    private  ReentrantLock lock = new ReentrantLock();
    private Condition condition = lock.newCondition();
    public void waitMethod(){
        try {
            lock.lock();
            condition.await();
        }catch (Exception e){
            e.printStackTrace();
        }finally {
            lock.unlock();
        }

    }

    public void signalMethod(){
        lock.lock();
        System.out.println("有线程在等待condition ？ " + lock.hasWaiters(condition) + "数量是：" + lock.getWaitQueueLength(condition) );
        lock.unlock();

    }
}
